package biz;

import dao.SizetbDAO;
import entity.SizetbEntity;

import java.sql.SQLException;
import java.util.List;

/*
 * @Description：
 *       尺寸表数据处理
 * @Author: JiangFan
 * @Date: 2019/3/8
 * @Time：15:15
 */
public class SizeBiz {
    SizetbDAO sd=new SizetbDAO ();
    /** 添加尺寸
     * @param se ce由servlet中获取
     * @return
     * @throws SQLException
     * @throws ClassNotFoundException
     */
    public int addSize (SizetbEntity se) throws SQLException, ClassNotFoundException {
        SizetbEntity c=sd.selectSizeOne (se.getSize_name ());
        return c==null?sd.insertSize (se):0;
    }

    /**查询所有尺寸信息
     * @return 返回到List集合
     */
    public List<SizetbEntity> querySizeAll ()
            throws ClassNotFoundException, SQLException, InstantiationException, IllegalAccessException {
        return sd.selectSizeAll ();
    }

    /** 查询尺寸是否可用
     * @param size_name
     * @return 返回true表示尺寸不存在
     * @throws SQLException
     * @throws ClassNotFoundException
     */
    public boolean checkSize(String size_name) throws SQLException, ClassNotFoundException {
        return sd.selectSizeOne (size_name)==null;
    }
}
